package zxj.spay.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * 类型
 * @author 朱小杰
 * 日期:2016-05-02
 */
@Table(name="type")
@Entity
public class Type implements Serializable{
	private static final long serialVersionUID = 3827366601909711131L;
	/**
	 * 收入
	 */
	public final static int STATUS_INCOME = 0;
	/**
	 * 支出
	 */
	public final static int STATUS_COST = 1;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int id;
	
	/**
	 * 0收入，1 支出
	 */
	private int status;
	
	/**
	 * 属性哪个用户建立出来的
	 */
	@JsonIgnore
	@JoinColumn(name="user_id",referencedColumnName="id")
	@ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.REFRESH})
	private User user;
	
	/**
	 * 类型名称
	 */
	@Column(nullable=false)
	private String typeName;
	
	/**
	 * 类型创建时间
	 */
	@Column(nullable=false)
	private Date createTime;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getTypeName() {
		return typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Override
	public String toString() {
		return "Type [id=" + id + ", status=" + status + ", user=" + user + ", typeName=" + typeName + ", createTime="
				+ createTime + "]";
	}

	
}
